namespace Maple.Branch.Identity
{
    using EfCoreConfigurations;
    using EfCoreRepositories;
    using Entities;
    using Extensions;
    using Microsoft.Extensions.DependencyInjection;
    using Users.EfCore;
    using Volo.Abp.EntityFrameworkCore;
    using Volo.Abp.Modularity;

    [DependsOn(typeof(IdentityDomainModule),
        typeof(AbpEntityFrameworkCoreModule),
        typeof(UsersEfCoreModule))]
    public class IdentityEfCoreModule : AbpModule
    {
        public override void ConfigureServices(ServiceConfigurationContext context)
        {
            context.Services.AddAbpDbContext<IdentityDbContext>(options =>
            {
                options.AddRepository<IdentityUser, IdentityUserRepository>();
                options.AddRepository<IdentityRole, IdentityRoleRepository>();
                options.AddRepository<IdentityClaimType, IdentityClaimTypeRepository>();

                options.Entity<IdentityUser>(opt =>
                {
                    opt.DefaultWithDetailsFunc = q => q.IncludeDetails();
                });

                options.Entity<IdentityRole>(opt =>
                {
                    opt.DefaultWithDetailsFunc = q => q.IncludeDetails();
                });
            });
        }
    }
}
